package com.pandora.credit.mongo.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.pandora.common.util.VerifyUtil;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.Date;
import java.util.List;

/**
 * @author developer
 */
@Document(collection = "pandora_credit")
public class MongoPandoraCredit {

    @Field("_id")
    @JsonProperty("_id")
    private Long id;
    @Field("created_time")
    @JsonProperty("created_time")
    private Date createdTime;
    private MongoPandoraCreditItem item;
    private Integer type;
    @Field("updated_time")
    @JsonProperty("updated_time")
    private Date updatedTime;

    public MongoPandoraCredit(){}

    public MongoPandoraCredit(Long id, Date createdTime, MongoPandoraCreditItem item, Integer type, Date updatedTime) {
        this.id = id;
        this.createdTime = createdTime;
        this.item = item;
        this.type = type;
        this.updatedTime = updatedTime;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(Date createdTime) {
        this.createdTime = createdTime;
    }

    public MongoPandoraCreditItem getItem() {
        return item;
    }

    public void setItem(MongoPandoraCreditItem item) {
        this.item = item;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Date getUpdatedTime() {
        return updatedTime;
    }

    public void setUpdatedTime(Date updatedTime) {
        this.updatedTime = updatedTime;
    }

    public static class MongoPandoraCreditItem{
        private Long id;
        private Integer status;
        private String name;
        private Integer type;
        @Field("bank_id")
        @JsonProperty("bank_id")
        private Long bankId;
        private Integer recommend;
        @Field("is_hot")
        @JsonProperty("is_hot")
        private Integer isHot;
        @Field("img_url")
        @JsonProperty("img_url")
        private String imgUrl;
        @Field("dest_url")
        @JsonProperty("dest_url")
        private String destUrl;
        private String description;
        private String organization;
        @Field("loan_name")
        @JsonProperty("loan_name")
        private String loanName;
        @Field("icon_url")
        @JsonProperty("icon_url")
        private String iconUrl;
        private Integer count;
        private MongoPandoraCreditItemFee fee;
        @Field("loan_period")
        @JsonProperty("loan_period")
        private MongoPandoraCreditItemFee loanPeriod;
        @Field("description_list")
        @JsonProperty("description_list")
        private List<String> descriptionList;
        private MongoPandoraCreditItemFee amount;
        @Field("approval_time")
        @JsonProperty("approval_time")
        private MongoPandoraCreditItemFee approvalTime;
        @Field("sub_tatil")
        @JsonProperty("sub_tatil")
        private List<String> subTatil;
        @Field("sub_list")
        @JsonProperty("sub_list")
        private List<String> subList;
        private Integer number;
        @Field("assort_id")
        @JsonProperty("assort_id")
        private Long assortId;
        @Field("type_id")
        @JsonProperty("type_id")
        private Long typeId;
        @Field("product_introduction")
        @JsonProperty("product_introduction")
        private String productIntroduction;
        @Field("applicable_peoplelist")
        @JsonProperty("applicable_peoplelist")
        private List<String> applicablePeopleList;
        @Field("company_introduction")
        @JsonProperty("company_introduction")
        private String companyIntroduction;
        @Field("material_requested")
        @JsonProperty("material_requested")
        private String materialRequested;
        @Field("applicable_people")
        @JsonProperty("applicable_people")
        private String applicablePeople;
        @Field("material_requestedlist")
        @JsonProperty("material_requestedlist")
        private List<String> materialRequestedlist;
        public MongoPandoraCreditItem(Long id, Integer status, String name, Integer type, Long bankId, Integer recommend,
                                      Integer isHot, String imgUrl, String destUrl, String description,
                                      String organization, String loanName, String iconUrl, Integer count,
                                      MongoPandoraCreditItemFee fee, MongoPandoraCreditItemFee loanPeriod,
                                      List<String> descriptionList, MongoPandoraCreditItemFee amount,
                                      MongoPandoraCreditItemFee approvalTime, List<String> subTatil, List<String> subList,
                                      Integer number, Long assortId, Long typeId, String productIntroduction,
                                      List<String> applicablePeopleList, String companyIntroduction,
                                      String materialRequested, String applicablePeople,
                                      List<String> materialRequestedlist) {
            this.id = id;
            this.status = status;
            this.name = name;
            this.type = type;
            this.bankId = bankId;
            this.recommend = recommend;
            this.isHot = isHot;
            this.imgUrl = imgUrl;
            this.destUrl = destUrl;
            this.description = description;
            this.organization = organization;
            this.loanName = loanName;
            this.iconUrl = iconUrl;
            this.count = count;
            this.fee = fee;
            this.loanPeriod = loanPeriod;
            this.descriptionList = descriptionList;
            this.amount = amount;
            this.approvalTime = approvalTime;
            this.subTatil = subTatil;
            this.subList = subList;
            this.number = number;
            this.assortId = assortId;
            this.typeId = typeId;
            this.productIntroduction = productIntroduction;
            this.applicablePeopleList = applicablePeopleList;
            this.companyIntroduction = companyIntroduction;
            this.materialRequested = materialRequested;
            this.applicablePeople = applicablePeople;
            this.materialRequestedlist = materialRequestedlist;
        }
        public Long getId() {
            return id;
        }
        public void setId(Long id) {
            this.id = id;
        }
        public Integer getStatus() {
            return status;
        }
        public void setStatus(Integer status) {
            this.status = status;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public Integer getType() {
            return type;
        }
        public void setType(Integer type) {
            this.type = type;
        }
        public Long getBankId() {
            return bankId;
        }
        public void setBankId(Long bankId) {
            this.bankId = bankId;
        }
        public Integer getRecommend() {
            return recommend;
        }
        public void setRecommend(Integer recommend) {
            this.recommend = recommend;
        }
        public Integer getIsHot() {
            return isHot;
        }
        public void setIsHot(Integer isHot) {
            this.isHot = isHot;
        }
        public String getImgUrl() {
            return imgUrl;
        }
        public void setImgUrl(String imgUrl) {
            this.imgUrl = imgUrl;
        }
        public String getDestUrl() {
            return destUrl;
        }
        public void setDestUrl(String destUrl) {
            this.destUrl = destUrl;
        }
        public List<String> getSubList() {
            return subList;
        }
        public void setSubList(List<String> subList) {
            this.subList = subList;
        }
        public String getDescription() {
            return description;
        }
        public void setDescription(String description) {
            this.description = description;
        }
        public String getOrganization() {
            return organization;
        }
        public void setOrganization(String organization) {
            this.organization = organization;
        }
        public String getLoanName() {
            return loanName;
        }
        public void setLoanName(String loanName) {
            this.loanName = loanName;
        }
        public String getIconUrl() {
            return iconUrl;
        }
        public void setIconUrl(String iconUrl) {
            this.iconUrl = iconUrl;
        }
        public Integer getCount() {
            return count;
        }
        public void setCount(Integer count) {
            this.count = count;
        }
        public MongoPandoraCreditItemFee getFee() {
            return fee;
        }
        public void setFee(MongoPandoraCreditItemFee fee) {
            this.fee = fee;
        }
        public MongoPandoraCreditItemFee getLoanPeriod() {
            return loanPeriod;
        }
        public void setLoanPeriod(MongoPandoraCreditItemFee loanPeriod) {
            this.loanPeriod = loanPeriod;
        }
        public List<String> getDescriptionList() {
            return descriptionList;
        }
        public void setDescriptionList(List<String> descriptionList) {
            this.descriptionList = descriptionList;
        }
        public MongoPandoraCreditItemFee getAmount() {
            return amount;
        }
        public void setAmount(MongoPandoraCreditItemFee amount) {
            this.amount = amount;
        }
        public MongoPandoraCreditItemFee getApprovalTime() {
            return approvalTime;
        }
        public void setApprovalTime(MongoPandoraCreditItemFee approvalTime) {
            this.approvalTime = approvalTime;
        }
        public List<String> getSubTatil() {
            return subTatil;
        }
        public void setSubTatil(List<String> subTatil) {
            this.subTatil = subTatil;
        }
        public Integer getNumber() {
            return number;
        }
        public void setNumber(Integer number) {
            this.number = number;
        }
        public Long getAssortId() {
            return assortId;
        }
        public void setAssortId(Long assortId) {
            this.assortId = assortId;
        }
        public Long getTypeId() {
            return typeId;
        }
        public void setTypeId(Long typeId) {
            this.typeId = typeId;
        }
        public String getProductIntroduction() {
            return productIntroduction;
        }
        public void setProductIntroduction(String productIntroduction) {
            this.productIntroduction = productIntroduction;
        }
        public List<String> getApplicablePeopleList() {
            return applicablePeopleList;
        }
        public void setApplicablePeopleList(List<String> applicablePeopleList) {
            this.applicablePeopleList = applicablePeopleList;
        }
        public String getCompanyIntroduction() {
            return companyIntroduction;
        }
        public void setCompanyIntroduction(String companyIntroduction) {
            this.companyIntroduction = companyIntroduction;
        }
        public String getMaterialRequested() {
            return materialRequested;
        }
        public void setMaterialRequested(String materialRequested) {
            this.materialRequested = materialRequested;
        }
        public String getApplicablePeople() {
            return applicablePeople;
        }
        public void setApplicablePeople(String applicablePeople) {
            this.applicablePeople = applicablePeople;
        }
        public List<String> getMaterialRequestedlist() {
            return materialRequestedlist;
        }
        public void setMaterialRequestedlist(List<String> materialRequestedlist) {
            this.materialRequestedlist = materialRequestedlist;
        }

        public Integer verifySize(){
            Integer cnt = 0;
            if(id != null){ cnt++; }
            if(status != null){ cnt++; }
            if(type != null){ cnt++; }
            if(bankId != null){ cnt++; }
            if(recommend != null){ cnt++; }
            if(isHot != null){ cnt++; }
            if(count != null){ cnt++; }
            if(number != null){ cnt++; }
            if(assortId != null){ cnt++; }
            if(typeId != null){cnt++; }

            if(!VerifyUtil.isEmpty(name)){ cnt++; }
            if(!VerifyUtil.isEmpty(imgUrl)){ cnt++; }
            if(!VerifyUtil.isEmpty(destUrl)){ cnt++; }
            if(!VerifyUtil.isEmpty(description)){ cnt++; }
            if(!VerifyUtil.isEmpty(organization)){ cnt++; }
            if(!VerifyUtil.isEmpty(loanName)){ cnt++; }
            if(!VerifyUtil.isEmpty(iconUrl)){ cnt++; }
            if(!VerifyUtil.isEmpty(productIntroduction)){ cnt++; }
            if(!VerifyUtil.isEmpty(companyIntroduction)){ cnt++; }
            if(!VerifyUtil.isEmpty(materialRequested)){ cnt++; }
            if(!VerifyUtil.isEmpty(applicablePeople)){ cnt++; }

            if(descriptionList != null && descriptionList.size() > 0){ cnt++; }
            if(subTatil != null && subTatil.size() > 0){ cnt++; }
            if(applicablePeopleList != null && applicablePeopleList.size() > 0){ cnt++; }
            if(materialRequestedlist != null && materialRequestedlist.size() > 0){ cnt++; }
            if(subList != null && subList.size() > 0){ cnt++; }

            if(fee != null){ cnt++; }
            if(loanPeriod != null){ cnt++; }
            if(amount != null){ cnt++; }
            if(approvalTime != null){ cnt++; }

            return cnt;
        }
    }

    public static class MongoPandoraCreditItemFee{
        private String value;
        private String unit;
        private Integer minimum;
        private Integer maximum;

        public MongoPandoraCreditItemFee(String value, String unit, Integer minimum, Integer maximum) {
            this.value = value;
            this.unit = unit;
            this.minimum = minimum;
            this.maximum = maximum;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        public String getUnit() {
            return unit;
        }

        public void setUnit(String unit) {
            this.unit = unit;
        }

        public Integer getMinimum() {
            return minimum;
        }

        public void setMinimum(Integer minimum) {
            this.minimum = minimum;
        }

        public Integer getMaximum() {
            return maximum;
        }

        public void setMaximum(Integer maximum) {
            this.maximum = maximum;
        }
    }
}
